
local Zhenghuo = fk.CreateSkill {
    name = "Zhenghuo",
}

Fk:loadTranslationTable{
    ["Zhenghuo"] = "整活",
    ["@@zhenghuo_used-round"] = "整活",
    [":Zhenghuo"] = "出牌阶段限一次，你可令任意名角色选择一项：1：本轮内使用的第一张牌无效，然后你摸两张牌；2：受到2点伤害，然后弃置x张牌(x为你体力值的一半向下取整)。",
    ["#ZhenghuoChoose"] = "整活：请选择一项",
    ["ZhenghuoOption1"] = "本轮内使用的第一张牌无效，然后其摸两张牌",
    ["ZhenghuoOption2"] = "受到2点伤害，然后其弃置x张牌(x为其体力值的一半向下取整)",
    ["#ZhenghuoDiscard"] = "整活：你需要弃置 %arg 张牌",
  } 


-- 整活技能定义
Zhenghuo:addEffect("active", {
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  
  card_filter = Util.TrueFunc,
  target_filter = function(self, to_select, selected)
    return true
  end,
  min_target_num = 1,
  on_use = function(self, room, effect)
      local player = effect.from
      for _, target in ipairs(effect.tos) do
        local choice = player.room:askToChoice(target, {
          choices = {"ZhenghuoOption1", "ZhenghuoOption2"},
          skill_name = self.name,
          prompt = "#ZhenghuoChoose",
        })
        if choice == "ZhenghuoOption1" then
          room:setPlayerMark(target, "@@zhenghuo_used-round", 1)
        else
          room:damage{
            from = target,
            to = target,
            damage = 2,
          }
          local discard_num = math.floor(player.hp / 2)
          room:askToDiscard(target, {
            min_num = discard_num,
            max_num = discard_num,
            cancelable = false,
            include_equip = true,
            prompt = "#ZhenghuoDiscard:::" .. discard_num,
            skill_name = self.name,
          })
        end
      end
  end,
})


Zhenghuo:addEffect(fk.PreCardEffect, {
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
      return player:hasSkill(Zhenghuo.name) and target and target:getMark("@@zhenghuo_used-round") == 1
  end,
  on_use = function(self, event, target, player, data)
      local room = player.room
      player:drawCards(2,Zhenghuo.name)
      data.nullified = true
      room:setPlayerMark(player, "@@zhenghuo_used-round", 0)
  end,
})



return Zhenghuo 